package com.yang.cloud.hystric;

import com.google.common.collect.Lists;
import com.yang.cloud.entity.User;
import com.yang.cloud.feign.UserFeignClient;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yang.yang@karakal.com.cn
 * @version V1.0
 * @Description: user服务熔断器
 * @date 2017-11-14 11:49
 */
@Component
public class UserFeignClientHystrix implements UserFeignClient{
    @Override
    public User findById(Long id) {
        User user = new User(id, "error","100010");
        return user;
    }

    @Override
    public User postUser(User user) {
        return null;
    }

    @Override
    public List<User> getUser() {
        ArrayList<User> list = Lists.newArrayList();
        User user = new User(1L, "hystric return","18");
        User user2 = new User(2L, "hystric return","18");
        User user3 = new User(3L, "hystric return","18");
        list.add(user);
        list.add(user2);
        list.add(user3);
        return list;
    }

    @Override
    public String eurekaInstance() {
        return "sorry!service error!!!";
    }

    @Override
    public ServiceInstance instanceInfo() {
        return null;
    }
}
